<?php
/**
 * Created by PhpStorm.
 * User: Duke
 * Date: 2019/12/2
 * Time: 17:36
 */
namespace App\Model;

use App\Model\BaseModel;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Events\StatementPrepared;
class ClockinModel extends BaseModel{
    //表名
    protected $table = 'clockin';

    //获取列表
    public function getAllList(){
        return DB::table($this->table)->get()->toArray();
    }

    //condition 获取单条数据
    public function find_info($condition){
        return DB::table($this->table)->where($condition)->first();
    }

    //condition 获取条件列表
    public function getConditionList($condition){
        return DB::table($this->table)->where($condition)->get()->toArray();
    }

    //保存数据
    public function insert_info($data){
        return DB::table($this->table)->insert([
            'uid'       =>  $data['uid'],
            'pid'       =>  $data['pid'],
            'status'    =>  '0',
            'addtime'   =>  time(),
        ]);
    }

    //修改数据
    public function update_info($data){
        return DB::table($this->table)->where('id',$data['id'])->update([
            'uid'       =>  $data['uid'],
            'pid'       =>  $data['pid'],
            'status'    =>  '0',
            'addtime'   =>  time(),
        ]);
    }

    //删除数据
    public function del($id = ''){
        return DB::table($this->table)->delete(['id'=>$id]);
    }

}
